<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ include file="/parameter.jsp" %>
<%@page isELIgnored="false"%>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<Meta http-equiv="Pragma" Content="No-cach">
<title>论坛首页</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function loginsubmit(){
	return document.forms["form1"].submit();
}
</script>
</HEAD>
<body>
<jsp:include page="inc/header.jsp"/>
		<header class="entry-header">
			<h1 class="entry-title">
				<span>论坛首页<div id="searchbar">
				<form name="form3" method="post" action="commonAction.do?method=SearchTopic">
					<input type="text" id="keywords" name="keywords" title="搜索"><button onClick="search();">搜索</button>
				</form>
				</div></span>
			</h1>
		</header>
		
		<div id="maindiv">
			<div id="nav">
			<c:choose>
				<c:when test="${sessionScope.user == null}">
					<div>
						<form name="form1" method="post" action="commonAction.do?method=UserLogin">
						账号：<input type="text" name="username"> 密码：<input type="password" name="password"> 
						<button onClick="loginsubmit();">登陆</button> <a href="commonAction.do?method=toRegister">注册新账号</a>
						</form>
					</div>
				</c:when>
				<c:otherwise>
					<div>
					&nbsp;&nbsp;${sessionScope.user.nickname}&nbsp;你好！<a
							href="commonAction.do?method=Logout">注销</a>&nbsp;|&nbsp;<a
							href="commonAction.do?method=EditUserInfo&uid=${sessionScope.user.id}">修改个人信息</a>&nbsp;|&nbsp;<a
							href="commonAction.do?method=EditUserPwd&uid=${sessionScope.user.id}">修改密码</a>
					</div>
				</c:otherwise>
			</c:choose>

				<a href="commonAction.do?method=index" title="首页">首页</a>
				<span>&gt;</span>
				<a href="###">搜索：${keywords}</a>

			</div>

			<div id="board">
				<div class="bm">
					<div id="post_c">
							<div class="bm_h"><h2>搜索 "<font color="red">${keywords}</font>" 结果：</h2></div>
							<div class="postcontent">
								<div class="searchlist">
									<ul>
										<c:forEach items="${TopicList}" var="topicList">
										<li>
											<c:choose><c:when test="${topicList.parentid == '0'}">
											<h3>&#8226;&nbsp;<A href="commonAction.do?method=TopicResponsInfo&topid=${topicList.id}">${fn:replace(topicList.title, keywords, newStr)}</a></h3>
											<p class="content">
                                            <c:choose><c:when test="${fn:indexOf(topicList.content, keywords) > 20}">
                                            ${fn:substring(fn:replace(topicList.content, keywords, newStr), fn:indexOf(topicList.content, keywords)-20, fn:indexOf(topicList.content, keywords)+100)}
                                            </c:when><c:otherwise>
                                            ${fn:substring(fn:replace(topicList.content, keywords, newStr), 0, fn:indexOf(topicList.content, keywords)+120)}
                                            </c:otherwise></c:choose>
                                            </p>
											<p class="meta">${topicList.date} - ${topicList.postuser.nickname} - 板块名<c:if test="${topicList.postkey != ''}"> - [${topicList.postkey}]</c:if></p>
											</c:when><c:otherwise>
											<h3>&#8226;&nbsp;<A href="commonAction.do?method=TopicResponsInfo&topid=${topicList.parentBean.id}">${fn:replace(topicList.parentBean.title, keywords, newStr)}</a></h3>
											<p class="content">
                                            <c:choose><c:when test="${fn:indexOf(topicList.content, keywords) > 20}">
                                            ${fn:substring(fn:replace(topicList.content, keywords, newStr), fn:indexOf(topicList.content, keywords)-20, fn:indexOf(topicList.content, keywords)+100)}
                                            </c:when><c:otherwise>
                                            ${fn:substring(fn:replace(topicList.content, keywords, newStr), 0, fn:indexOf(topicList.content, keywords)+120)}
                                            </c:otherwise></c:choose>
                                            </p>
											<p class="meta">${topicList.date} - ${topicList.postuser.nickname} - 板块名<c:if test="${topicList.parentBean.postkey != ''}"> - [${topicList.parentBean.postkey}]</c:if></p>
											</c:otherwise></c:choose>
										</li>
										</c:forEach>
									</ul>
								</div>
							</div>
					</div>
				</div>
			</div>
					<div class="pgt cl">
						<div class="pg" style="float:none;">
							 <tools:page pagerName="commonAction.do" pagerSum="${pagerSum}" pagerSize="${pagerSize}"/>
						</div>
					</div>

		</div>
<jsp:include page="inc/footer.jsp"/>
</body>
</HTML>